package com.antler.smt.portal.controller;

import com.antler.smt.portal.annotation.OperateCut;
import com.antler.smt.response.admin.GetOrderListResp;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.ExcellentCaseService;
import com.antler.smt.service.portal.OrderService;
import com.antler.smt.utils.LogUtil;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 获取优秀案例中的详情
 *
 * @author zhangyi
 * @date 2018/5/8 15:15
 */
@RestController
@RequestMapping("/excellentCase")
@Api(description = "获取优秀案例中的详情" )
public class ExcellentCaseController extends BaseController{

    /**
     * 日志
     */
    private static Logger log = LogUtil.get();

    @Resource
    private ExcellentCaseService excellentCaseService;

    @Resource
    private OrderService orderService;
    /**
     * 优秀案例详情页
     *
     * @return
     */
    @PostMapping("/excellentCaseInfo")
    @ApiOperation(value = "首页的优秀案例详情页", httpMethod = "POST")
    @OperateCut(operationContent = "查询优秀案例详情页")
    public Result<GetOrderListResp> excellentCaseInfo(@RequestParam(value = "orderId") Long orderId){
        DataValidator.isBlank(String.valueOf(orderId),"订单id不能为空!");
        Result result = null;
        result = orderService.getOrderList(orderId,currentMember.getId());
        return result;
    }

    /**
     * 优秀加工厂详情页
     *
     * @return
     */
    @PostMapping("/excellentSupplierInfo")
    @ApiOperation(value = "优秀加工厂详情页", httpMethod = "POST")
    @OperateCut(operationContent = "查询优秀加工厂详情页")
    public Result excellentSupplierInfo(@RequestParam(value = "supplierId") Long supplierId){

        DataValidator.isBlank(String.valueOf(supplierId),"服务商id不能为空!");
        Result result = null;
        result = excellentCaseService.getExcellentSupplierInfo(supplierId);
        return result;
    }
}
